//
//  DDCartHotSaleCollectionCell.m
//  Dingdong
//
//  Created by 程强 on 16/12/20.
//  Copyright © 2016年 程强. All rights reserved.
//

#import "DDCartHotSaleCollectionCell.h"

@implementation DDCartHotSaleCollectionCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.goodsIcon = [[UIImageView alloc]init];
        [self.contentView addSubview:_goodsIcon];
        [_goodsIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(self.contentView).offset(5);
            make.right.equalTo(self.contentView).offset(-5);
            make.height.equalTo(_goodsIcon.mas_width);
        }];
        
        self.goodsNameLbl = [[KKLabel alloc]initWithBlock:^(KKLabel *lbl) {
            lbl.laText(@"",[UIColor grayColor],[UIFont systemFontOfSize:12.0],NSTextAlignmentLeft);
        }];
        _goodsNameLbl.numberOfLines = 0;
        [self.contentView addSubview:_goodsNameLbl];
        [_goodsNameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_goodsIcon.mas_bottom).offset(3);
            make.left.equalTo(self.contentView).offset(5);
            make.right.equalTo(self.contentView).offset(-5);
            make.height.equalTo(@40);
        }];
        
        self.goodsPriceLbl = [[KKLabel alloc]initWithBlock:^(KKLabel *lbl) {
            lbl.laText(@"",RGBColor(255, 80, 80),[UIFont systemFontOfSize:15.0],NSTextAlignmentLeft);
        }];
        [self.contentView addSubview:_goodsPriceLbl];
        [_goodsPriceLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(5);
            make.top.equalTo(_goodsNameLbl.mas_bottom).offset(3);
            make.width.equalTo(@100);
            make.height.equalTo(@20);
        }];
        
//        self.addCartBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//        [_addCartBtn setBackgroundImage:LoadImage(@"category_cart") forState:UIControlStateNormal];
//        [_addCartBtn addTarget:self action:@selector(addCartClick:) forControlEvents:UIControlEventTouchUpInside];
//        [self.contentView addSubview:_addCartBtn];
//        [_addCartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.width.height.equalTo(@22);
//            make.centerY.equalTo(_goodsPriceLbl);
//            make.right.equalTo(self.contentView).offset(-20);
//        }];
        
    }
    return self;
}
- (void)addCartClick:(UIButton *)sender
{
    if (self.cartBlock) {
        self.cartBlock();
    }
}
- (void)userHotSaleAddCart:(AddCartHandler)handler
{
    self.cartBlock = handler;
}
@end
